/**
 *学生基本信息管理模块
 **/
$(function () {
    //学部列表
    $('#manager-student').datagrid({
        url: Think.APP + "Student/index&cmd=InfoStudent", //数据源
        fit: true, //自适应
        striped: true,
        fitColumns: true,
        toolbar: '#student-toolbar',
        border: false, //取消边框
        pagination: true, //分页开启
        pageSize: 50,
        rownumbers: true,
        columns: [[
                {title: 'ID', field: '', checkbox: true},
                {field: 'is_id', title: '学号', width: 100, align: 'center'},
                {field: 'is_name', title: '名称', width: 100, align: 'center'},
                {field: 'is_sex', title: '性别', width: 100, align: 'center'},
                {field: 'ico_id', title: '学部', width: 100, align: 'center', formatter: function (value, row, index) {
                        if (value <= 0) {
                            return "无";
                        }
                        return Store().converter(app_data.info.college("STORE"), value);
                    }},
                {field: 'id_id', title: '专业', width: 100, align: 'center', formatter: function (value, row, index) {
                        if (value <= 0) {
                            return "无";
                        }
                        return Store().converter(app_data.info.discipline("STORE"), value);
                    }},
                {field: 'icl_id', title: '班级', width: 100, align: 'center', formatter: function (value, row, index) {
                        if (value <= 0) {
                            return "无";
                        }
                        return Store().converter(app_data.info.classinfo("STORE"), value);
                    }},
                {field: 'is_study_date', title: '入学日期', width: 100, align: 'center'},
                {field: 'is_grade', title: '年级', width: 100, align: 'center'},
                {field: 'icl_number', hidden:true, width: 100, align: 'center'},
            ]],
        onClickRow: function (rowIndex, rowData) {//单击事件
            $('#manager-student').datagrid("clearChecked"); //取消所有行的选中
            $('#manager-student').datagrid("selectRow", rowIndex);  //选中当前行
        },
        onDblClickRow:function(field, row){
            var url =  Think.APP + "Student/edit&cmd=InfoStudent&is_id=" + row.is_id;
            //打开弹出窗口
            Xwindow.baseDialogInit("#manager-student", "#add-student-form", "修改学生",url,row,3);
        }
    });

    //添加方法
    student_toolbar = {
        addStudent: function () {  //添加
            var url =  Think.APP + "Student/insert&cmd=InfoStudent";
            //打开弹出窗口
             Xwindow.baseDialogInit("#manager-student", "#add-student-form", "添加学生",url);
        },
        //导入学生信息
        importStudent:function(){
            Xwindow.upload(Think.APP + "Student/uploadStudentStep1",
                           Think.APP + "Student/uploadStudentStep2");
        },
        //搜索学生信息
        searchStudent:function(value, name){
                $('#manager-student').datagrid("load", {
                    "is_id": value
                });
        },
        deleteStudent:function(){
            var url = Think.APP + "Student/del&cmd=InfoStudent";
            Xwindow.baseDelete( "#manager-student",url,"is_id");
        }
    };

});